<template>
    <view class="page">
        <select-origin-house :h_id.sync="form.h_id" :show="showPop" :houseList="houseList" @cancel="showPop=false;"></select-origin-house>
        <view class="content">
            <view class="title">
                基本信息
            </view>
            <view class="_lists">
                <text>房东姓名</text>
                <input v-model="form.name" type="text" placeholder="请输入房东姓名"/>
            </view>
            <view class="_lists">
                <text>证件号码</text>
                <input v-model="form.num" type="text" placeholder="请输入证件号码"/>
            </view>
            <view class="_lists">
                <text>房东电话</text>
                <input v-model="form.phone" type="text" placeholder="请输入房东电话"/>
            </view>
            <view class="_lists">
                <text>转款姓名</text>
                <input v-model="form.tran_name" type="text" placeholder="请输入转款姓名"/>
            </view>
            <view class="_lists">
                <text>银行名称</text>
                <input v-model="form.bank_name" type="text" placeholder="请输入银行名称"/>
            </view>
            <view class="_lists">
                <text>银行卡号</text>
                <input v-model="form.bank_num" type="text" placeholder="请输入银行卡号"/>
            </view>

            <!-- 托管信息 -->
            <view class="title">
                托管信息
            </view>
            <view class="_lists">
                <text>开始时间</text>
                <input v-model="form.care_time_start" type="text" placeholder="请输入开始时间"/>
            </view>
            <view class="_lists">
                <text>合同期限</text>
                <input v-model="form.contract_time" type="text" placeholder="请输入合同期限"/>
            </view>
            <view class="_lists">
                <text>到期时间</text>
                <input v-model="form.care_time_end" type="text" placeholder="请输入到期时间"/>
            </view>
            <view class="_lists">
                <text>收房价格</text>
                <input v-model="form.put_money" type="text" placeholder="请输入收房价格"/>
            </view>
            <view class="_lists">
                <text>房屋押金</text>
                <input v-model="form.cash_money" type="text" placeholder="请输入房屋押金"/>
            </view>
            <view class="_lists">
                <text>缴费方式</text>
                <input v-model="form.pay_type" type="text" placeholder="请输入缴费方式"/>
            </view>
            <view class="_lists">
                <text>提前天数</text>
                <input v-model="form.ahead_day" type="text" placeholder="请输入提前天数"/>
            </view>
            <view class="_lists">
                <text>延后天数</text>
                <input v-model="form.carry_day" type="text" placeholder="请输入延后天数"/>
            </view>
            <!-- 备注信息 -->
            <view class="title">
                备注信息
            </view>
            <view class="" style="width: 100%;height:150rpx; border: 1px solid #C0C0C0;overflow: hidden;">
                <editor placeholder="如房子情况,房东租客情况,注意事项等" v-model="form.remake"></editor>
            </view>

            <u-gap height="50"></u-gap>
            <u-row>
                <u-button type="primary" text="提交" @click="submitHandler"></u-button>
            </u-row>
            <view class="safe-area-inset-bottom"></view>
        </view>
    </view>
</template>

<script>
    import SelectOriginHouse from './components/SelectOriginHouse';

    export default {
        name: "register",
        components:{
            SelectOriginHouse
        },
        data() {
            return {
                showPop:true,
                houseList:[],
                form: {
                    u_id: '',
                    h_id: '',
                    name: '',
                    num: '',
                    phone: '',
                    tran_name: '',
                    bank_name: '中国银行',
                    bank_num: '',
                    care_time_start: '',
                    contract_time: '',
                    care_time_end: '',
                    put_money: '',
                    cash_money: '',
                    pay_type: '',
                    ahead_day: '',
                    carry_day: '',
                    remake: '',
                }
            };
        },
        onLoad(){
            uni.$u.http.get('/api.php/House/house_list',
                {params:{u_id:uni.getStorageSync('u_id')}}).then(res => {
                this.houseList = res;
            });
        },
        methods: {
            submitHandler() {
                uni.$u.http.post('/api.php/house/owner_do', this.form).then(res => {
                    uni.showToast({
                        title: '添加成功', //提示文字
                        duration: 3000, //显示时长
                        icon: "none", //图标，支持"success"、"loading"
                    });
                });
            }
        }
    }
</script>

<style lang="scss" scoped>
    .page {
        width: 100%;
        min-height: 100vh;
        /*background-color: RGBA(245, 245, 245, 1);*/
        background-color: #f3f4f6;
    }

    .content {
        padding: 20rpx;
        overflow: hidden;
        ._lists {
            margin-top: 20rpx;
            border-bottom: 1px solid #C0C0C0;
            width: 100%;
            height: 60rpx;
            // background-color: yellow;
            input {
                width: 70%;
                height: 60rpx;
                line-height: 60rpx;
                display: inline-block;
                vertical-align: top;
                font-size: 14px;
                margin-left: 20rpx;
                padding-left: 20rpx;
                border-left: 1px solid #C0C0C0;
            }
            text {
                display: inline-block;
                text-align: center;
                width: 20%;
                height: 60rpx;
                line-height: 60rpx;
            }
        }
        .title {
            width: 100%;
            height: 50rpx;
            color: #007AFF;
            margin-top: 30rpx;
        }
    }
</style>
